﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Web;

namespace DuelQuizzServer
{
    [DataContract]
    public class Leaderboard
    {
        [DataMember]
        public Dictionary<int, User> leaderboard;
        
        [DataMember]
        public int current_position = 500;

        public Leaderboard(User current_player = null)
        {
            leaderboard = new  Dictionary<int, User>();
            List<User> list = User.getLeaderboard();
            int i = 1;

            foreach (User u in list)
            {
                if (current_player != null)
                    if (current_player.id == u.id)
                        current_position = i;

                leaderboard.Add(i++, u);
            }

        }
    }
}